package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CowNum;
import com.ruoyi.system.service.ICowNumService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 牛号对应Controller
 * 
 * @author ruoyi
 * @date 2025-02-16
 */
@RestController
@RequestMapping("/system/num")
public class CowNumController extends BaseController
{
    @Autowired
    private ICowNumService cowNumService;

    /**
     * 查询牛号对应列表
     */
    @PreAuthorize("@ss.hasPermi('system:num:list')")
    @GetMapping("/list")
    public TableDataInfo list(CowNum cowNum)
    {
        startPage();
        List<CowNum> list = cowNumService.selectCowNumList(cowNum);
        return getDataTable(list);
    }

    /**
     * 导出牛号对应列表
     */
    @PreAuthorize("@ss.hasPermi('system:num:export')")
    @Log(title = "牛号对应", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CowNum cowNum)
    {
        List<CowNum> list = cowNumService.selectCowNumList(cowNum);
        ExcelUtil<CowNum> util = new ExcelUtil<CowNum>(CowNum.class);
        util.exportExcel(response, list, "牛号对应数据");
    }

    /**
     * 获取牛号对应详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:num:query')")
    @GetMapping(value = "/{耳号}")
    public AjaxResult getInfo(@PathVariable("耳号") String 耳号)
    {
        return success(cowNumService.selectCowNumBy耳号(耳号));
    }

    /**
     * 新增牛号对应
     */
    @PreAuthorize("@ss.hasPermi('system:num:add')")
    @Log(title = "牛号对应", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CowNum cowNum)
    {
        return toAjax(cowNumService.insertCowNum(cowNum));
    }

    /**
     * 修改牛号对应
     */
    @PreAuthorize("@ss.hasPermi('system:num:edit')")
    @Log(title = "牛号对应", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CowNum cowNum)
    {
        return toAjax(cowNumService.updateCowNum(cowNum));
    }

    /**
     * 删除牛号对应
     */
    @PreAuthorize("@ss.hasPermi('system:num:remove')")
    @Log(title = "牛号对应", businessType = BusinessType.DELETE)
	@DeleteMapping("/{耳号s}")
    public AjaxResult remove(@PathVariable String[] 耳号s)
    {
        return toAjax(cowNumService.deleteCowNumBy耳号s(耳号s));
    }
}
